package com.fivefu.core.hik.controller;

import com.alibaba.fastjson.JSON;
import com.fivefu.base.common.utils.str.StrUtils;
import com.fivefu.base.web.controller.BaseController;
import com.fivefu.base.web.vo.ResultInfo;
import com.fivefu.core.hik.dto.response.ResponsePage;
import com.fivefu.core.hik.entity.DbHikCamera;
import com.fivefu.core.hik.services.DbHikCameraService;
import com.fivefu.core.hik.services.VideoService;
import com.fivefu.core.hik.vo.VideoOSDVo;
import com.fivefu.module.dictionary.entity.DbSysDict;
import com.fivefu.module.dictionary.service.DbSysDictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

@Api(tags = "视频能力")
@RestController
@RequestMapping("/hikvideo")
public class DbHikVideoController extends BaseController {

    private static final Logger logger = LoggerFactory.getLogger(DbHikVideoController.class);

    @Autowired
    private VideoService videoService;
    @Autowired
    private DbHikCameraService dbHikCameraService;
    @Autowired
    private DbSysDictService dbSysDictService;

    @ApiOperation(value = "视频能力_视频预览",httpMethod = "POST",response = ResultInfo.class,notes = "视频预览-录像回放-语音对讲")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "监控点唯一标识",name = "cameraIndexCode",paramType = "query", required = true, dataType = "String"),
            @ApiImplicitParam(value = "取流协议(hik,rtsp,rtmp,hls,ws,默认hik)",name = "protocol",paramType = "query", required = false, dataType = "String"),
    })
    @RequestMapping(path = "/getCameraPreviewURL",method = RequestMethod.POST)
    public ResultInfo getCameraPreviewURL(String cameraIndexCode, String protocol) {
        logger.info("获取监控点播放地址接收参数：" + JSON.toJSONString(request.getParameterMap()));
        try {
            if (StrUtils.isNull(cameraIndexCode)) {
                return ResultInfo.renderError("监控点唯一标识不能为空");
            }
            String url = videoService.getCameraPreviewURLs(cameraIndexCode,protocol);
            return ResultInfo.renderSuccess(JSON.parseObject(url));
        } catch (Exception e) {
            logger.error(e.getMessage(),e);
            return ResultInfo.renderError("获取监控点播放地址失败");
        }
    }

    @ApiOperation(value = "视频能力_录像回放",httpMethod = "POST",response = ResultInfo.class,notes = "视频能力_录像回放")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "监控点唯一标识",name = "cameraIndexCode",paramType = "query", required = true, dataType = "String"),
//            @ApiImplicitParam(value = "存储类型(0:中心存储,1:设备存储,默认0)",name = "recordLocation",paramType = "query", required = false, dataType = "int"),
            @ApiImplicitParam(value = "取流协议(hik,rtsp,rtmp,hls,ws,默认hik)(hls协议只支持云存储，不支持设备存储)",name = "protocol",paramType = "query", required = false, dataType = "String"),
            @ApiImplicitParam(value = "开始查询时间(yyyy-MM-dd HH:mm:ss)",name = "sTime",paramType = "query", required = true, dataType = "String"),
            @ApiImplicitParam(value = "结束查询时间(yyyy-MM-dd HH:mm:ss)(时间间隔不得超过3天)",name = "eTime",paramType = "query", required = true, dataType = "String")
    })
    @RequestMapping(path = "/getCameraBackURL",method = RequestMethod.POST)
    public ResultInfo getCameraBackURL(String cameraIndexCode, String protocol,String sTime,String eTime) {
        logger.info("获取监控点录像回放请求参数为：" + JSON.toJSONString(request.getParameterMap()));
        try {
            if (StrUtils.isNull(cameraIndexCode)) {
                return ResultInfo.renderError("监控点唯一标识不能为空");
            }
            if (StrUtils.isNull(sTime) || StrUtils.isNull(eTime)) {
                return ResultInfo.renderError("开始查询时间或结束查询时间不能为空");
            }
            DbHikCamera detail = dbHikCameraService.queryCameraByIndexCode(cameraIndexCode);
            if (detail == null){
                return ResultInfo.renderError("监控点不存在");
            }
            if (StrUtils.isNull(detail.getRecordLocation())){
                return ResultInfo.renderError("监控点未配置录像计划");
            }
            //获取存储位置
            Integer recordLocation = null;
            if (!detail.getRecordLocation().contains(",")){
                DbSysDict dict = dbSysDictService.queryDictDetail(null,detail.getRecordLocation());
                if (dict != null && StrUtils.isNotNull(dict.getDictValue())){
                    recordLocation = Integer.parseInt(dict.getDictValue());
                }
            }
            String url = videoService.getCameraBackURL(cameraIndexCode,recordLocation,protocol,sTime,eTime);
            return ResultInfo.renderSuccess(JSON.parseObject(url));
        } catch (Exception e) {
            logger.error(e.getMessage(),e);
            return ResultInfo.renderError("获取监控点录像回放失败");
        }
    }

    @ApiOperation(value = "视频预览-语音对讲",httpMethod = "POST",response = ResultInfo.class,notes = "视频预览-语音对讲")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "监控点唯一标识",name = "cameraIndexCode",paramType = "query", required = true, dataType = "String"),
    })
    @RequestMapping(path = "/getCamerasTalkURLs",method = RequestMethod.POST)
    public ResultInfo getCamerasTalkURLs(String cameraIndexCode) {
        logger.info("视频预览-语音对讲请求参数为：" + JSON.toJSONString(request.getParameterMap()));
        try {
            if (StrUtils.isNull(cameraIndexCode)) {
                return ResultInfo.renderError("监控点唯一标识不能为空");
            }
            videoService.getCamerasTalkURLs(cameraIndexCode);
            return ResultInfo.renderSuccess("视频预览-语音对讲成功");
        } catch (Exception e) {
            logger.error("视频预览-语音对讲出现异常：" + e.getMessage(),e);
            return ResultInfo.renderError("视频预览-语音对讲失败");
        }
    }

    @ApiOperation(value = "视频预览-抓图",httpMethod = "POST",response = ResultInfo.class,notes = "视频预览-抓图")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "监控点唯一标识",name = "cameraIndexCode",paramType = "query", required = true, dataType = "String"),
    })
    @RequestMapping(path = "/getManualCapture",method = RequestMethod.POST)
    public ResultInfo getManualCapture(String cameraIndexCode) {
        logger.info("视频预览-抓图请求参数为：" + JSON.toJSONString(request.getParameterMap()));
        try {
            if (StrUtils.isNull(cameraIndexCode)) {
                return ResultInfo.renderError("监控点唯一标识不能为空");
            }
            String imageUrl = videoService.getManualCapture(cameraIndexCode);
            return ResultInfo.renderSuccess(200,"视频预览-抓图成功",imageUrl);
        } catch (Exception e) {
            logger.error("视频预览-抓图出现异常：" + e.getMessage(),e);
            return ResultInfo.renderError("视频预览-抓图失败");
        }
    }

    @ApiOperation(value = "云台操作",httpMethod = "POST",response = ResultInfo.class,notes = "云台操作")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "监控点唯一标识",name = "cameraIndexCode",paramType = "query",required = true,dataType = "String"),
            @ApiImplicitParam(value = "动作(0:开始，1：停止)",name = "action",paramType = "query",required = true,dataType = "int"),
            @ApiImplicitParam(value = "操作类型(LEFT 左转,RIGHT右转,UP 上转,DOWN 下转,LEFT_UP 左上,LEFT_DOWN 左下,RIGHT_UP 右上,RIGHT_DOWN 右下,\n" +
                    "ZOOM_IN 焦距变大,ZOOM_OUT 焦距变小,FOCUS_NEAR 焦点前移,FOCUS_FAR 焦点后移,\n" +
                    "IRIS_ENLARGE 光圈扩大,IRIS_REDUCE 光圈缩小,\n" +
                    "WIPER_SWITCH 接通雨刷开关,\n" +
                    "START_RECORD_TRACK 开始记录轨迹,STOP_RECORD_TRACK 停止记录轨迹,START_TRACK 开始轨迹,STOP_TRACK 停止轨迹,\n" +
                    "GOTO_PRESET到预置点)",name = "operation",paramType = "query",required = true,dataType = "String"),
            @ApiImplicitParam(value = "速度(取值范围为1-100，默认50)",name = "speed",paramType = "query",required = false,dataType = "int"),
            @ApiImplicitParam(value = "预置点编号(操作类型为GOTO_PRESET时必填)",name = "presetIndex",paramType = "query",required = false,dataType = "int"),
    })
    @RequestMapping(path = "/operationHolder",method = RequestMethod.POST)
    public ResultInfo operationHolder(String cameraIndexCode, Integer action, String operation,Integer speed, Integer presetIndex){
        logger.info("云台操作请求参数为：" + JSON.toJSONString(request.getParameterMap()));
        try {
            if (StrUtils.isNull(cameraIndexCode)) {
                return ResultInfo.renderError("监控点唯一标识不能为空");
            }
            if (null == action) {
                return ResultInfo.renderError("转到预置点不能为空");
            }
            if (StrUtils.isNull(operation)) {
                return ResultInfo.renderError("操作类型不能为空");
            }
            if (operation.equals("GOTO_PRESET")){
                if (presetIndex == null) {
                    return ResultInfo.renderError("预置点编号不能为空");
                }
            }
            DbHikCamera detail = dbHikCameraService.queryCameraByIndexCode(cameraIndexCode);
            if (detail == null){
                return ResultInfo.renderError("监控点不存在");
            }
            if (StrUtils.isNull(detail.getCapability())){
                return ResultInfo.renderError("该监控点不支持云台操作");
            }
            DbSysDict dict = dbSysDictService.queryDictByValue("CP", "ptz");
            String[] arr = detail.getCapability().split(",");
            List<String> list = Arrays.stream(arr).collect(Collectors.toList());
            if (!list.contains(dict.getDictCode())){
                return ResultInfo.renderError("该监控点不支持云台操作");
            }
            if (detail.getCameraType().equals("CTP1")){
                return ResultInfo.renderError("枪机不支持云台操作");
            }
            videoService.operationHolder(cameraIndexCode,action,operation,speed,presetIndex);
            return ResultInfo.renderSuccess("云台操作成功");
        } catch (Exception e) {
            logger.error("云台操作出现异常：" + e.getMessage(),e);
            return ResultInfo.renderError("云台操作失败");
        }
    }

    @ApiOperation(value = "3D放大",httpMethod = "POST",response = ResultInfo.class,notes = "3D放大")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cameraIndexCode",value = "监控点唯一标识",paramType = "query",required = true,dataType = "String"),
            @ApiImplicitParam(name = "startX",value = "开始放大的X坐标（0~255）",paramType = "query",required = true,dataType = "int"),
            @ApiImplicitParam(name = "startY",value = "开始放大的Y坐标（0~255）",paramType = "query",required = true,dataType = "int"),
            @ApiImplicitParam(name = "endX",value = "结束放大的X坐标（0~255）",paramType = "query",required = true,dataType = "int"),
            @ApiImplicitParam(name = "endY",value = "结束放大的Y坐标（0~255）",paramType = "query",required = true,dataType = "int")
    })
    @RequestMapping(path = "/threeDAmplification",method = RequestMethod.POST)
    public ResultInfo threeDAmplification(String cameraIndexCode,Integer startX,Integer startY,Integer endX,Integer endY) {
        logger.info("3D放大请求参数为：" + JSON.toJSONString(request.getParameterMap()));
        try {
            if (StrUtils.isNull(cameraIndexCode)) {
                return ResultInfo.renderError("监控点唯一标识不能为空");
            }
            if (null == startX) {
                return ResultInfo.renderError("开始放大的X坐标不能为空");
            }
            if (null == startY) {
                return ResultInfo.renderError("开始放大的Y坐标不能为空");
            }
            if (null == endX) {
                return ResultInfo.renderError("结束放大的X坐标不能为空");
            }
            if (null == endY) {
                return ResultInfo.renderError("结束放大的Y坐标不能为空");
            }
            videoService.threeDAmplification(cameraIndexCode,startX,startY,endX,endY);
            return ResultInfo.renderSuccess("3D放大成功");
        } catch (Exception e) {
            logger.error("3D放大出现异常：" + e.getMessage(),e);
            return ResultInfo.renderError("3D放大失败");
        }

    }

    @ApiOperation(value = "手动录像-录像锁定与解锁",httpMethod = "POST",response = ResultInfo.class,notes = "手动录像-录像锁定与解锁")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cameraIndexCode",value = "监控点唯一标识",paramType = "query",required = true,dataType = "String"),
            @ApiImplicitParam(name = "startTime",value = "开始时间",paramType = "query",required = true,dataType = "String"),
            @ApiImplicitParam(name = "endTime",value = "结束时间",paramType = "query",required = true,dataType = "String"),
            @ApiImplicitParam(name = "lockTime",value = "锁定时长(0~1576800000)",paramType = "query",required = true,dataType = "int")
    })
    @RequestMapping(path = "/lockVideo",method = RequestMethod.POST)
    public ResultInfo lockVideo(String cameraIndexCode,String startTime,String endTime,Integer lockTime) {
        logger.info("手动录像-录像锁定与解锁请求参数为：" + JSON.toJSONString(request.getParameterMap()));
        try {
            if (StrUtils.isNull(cameraIndexCode)) {
                return ResultInfo.renderError("监控点唯一标识不能为空");
            }
            if (StrUtils.isNull(startTime)) {
                return ResultInfo.renderError("开始时间不能为空");
            }
            if (StrUtils.isNull(endTime)) {
                return ResultInfo.renderError("结束时间不能为空");
            }
            if (null == lockTime) {
                return ResultInfo.renderError("锁定时长不能为空");
            }
            videoService.lockVideo(cameraIndexCode,startTime,endTime,lockTime);
            return ResultInfo.renderSuccess("手动录像-录像锁定与解锁成功");
        } catch (Exception e) {
            logger.error("手动录像-录像锁定与解锁出现异常：" + e.getMessage(),e);
            return ResultInfo.renderError("手动录像-录像锁定与解锁失败");
        }
    }

    @ApiOperation(value = "手动录像-开关手动录像",httpMethod = "POST",response = ResultInfo.class,notes = "手动录像-开关手动录像")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cameraIndexCode",value = "监控点唯一标识",paramType = "query",required = true,dataType = "String"),
            @ApiImplicitParam(name = "operation",value = "操作类型（1：开始，2：关闭）",paramType = "query",required = true,dataType = "int"),
            @ApiImplicitParam(name = "recordType",value = "录像类型",paramType = "query",required = false,dataType = "int")
    })
    @RequestMapping(path = "/switchVideo",method = RequestMethod.POST)
    public ResultInfo switchVideo(String cameraIndexCode,Integer operation,Integer recordType){
        logger.info("手动录像-开关手动录像请求参数为：" + JSON.toJSONString(request.getParameterMap()));
        try {
            if (StrUtils.isNull(cameraIndexCode)) {
                return ResultInfo.renderError("监控点唯一标识不能为空");
            }
            if (null == operation) {
                return ResultInfo.renderError("操作类型不能为空");
            }
            if (1 == operation) {
                if (null == recordType) {
                    return ResultInfo.renderError("录像类型不能为空");
                }
            }
            videoService.switchVideo(cameraIndexCode,operation,recordType);
            return ResultInfo.renderSuccess("手动录像-开关手动录像成功");
        } catch (Exception e) {
            logger.error("手动录像-开关手动录像出现异常：" + e.getMessage(),e);
            return ResultInfo.renderError("手动录像-开关手动录像失败");
        }
    }

    @ApiOperation(value = "手动录像-获取手动录像状态",httpMethod = "POST",response = ResultInfo.class,notes = "手动录像-获取手动录像状态")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cameraIndexCode",value = "监控点唯一标识",paramType = "query",required = true,dataType = "String")
    })
    @RequestMapping(path = "/getVideoStatus",method = RequestMethod.POST)
    public ResultInfo getVideoStatus(String cameraIndexCode) {
        logger.info("手动录像-获取手动录像状态请求参数为：" + JSON.toJSONString(request.getParameterMap()));
        try {
            if (StrUtils.isNull(cameraIndexCode)) {
                return ResultInfo.renderError("监控点唯一标识不能为空");
            }
            videoService.getVideoStatus(cameraIndexCode);
            return ResultInfo.renderSuccess("手动录像-获取手动录像状态成功");
        } catch (Exception e) {
            logger.error("手动录像-获取手动录像状态出现异常：" + e.getMessage(),e);
            return ResultInfo.renderError("手动录像-获取手动录像状态失败");
        }
    }


    @ApiOperation(value = "手动录像-查询手动录像编号",httpMethod = "POST",response = ResultInfo.class,notes = "手动录像-查询手动录像编号")
    @ApiImplicitParam(name = "idList",value = "监控点编号集合",paramType = "query",required = true,dataType = "String")
    @RequestMapping(path = "/getVideoNumber",method = RequestMethod.POST)
    public ResultInfo getVideoNumber(String idList) {
        logger.info("手动录像-查询手动录像编号请求参数为：" + JSON.toJSONString(request.getParameterMap()));
        try {
            if (StrUtils.isNull(idList)) {
                return ResultInfo.renderError("监控点编号不能为空");
            }
            String[] cameraIndexCodes = idList.split(",");
            videoService.getVideoNumber(cameraIndexCodes);
            return ResultInfo.renderSuccess("手动录像-查询手动录像编号成功");
        } catch (Exception e) {
            logger.error("手动录像-查询手动录像编号出现异常：" + e.getMessage(),e);
            return ResultInfo.renderError("手动录像-查询手动录像编号失败");
        }
    }

    @ApiOperation(value = "预置点管理-设置预置点信息",httpMethod = "POST",response = ResultInfo.class,notes = "预置点管理-设置预置点信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cameraIndexCode",value = "监控点唯一标识",paramType = "query",required = true,dataType = "String"),
            @ApiImplicitParam(name = "presetName",value = "预置点名称",paramType = "query",required = true,dataType = "String"),
            @ApiImplicitParam(name = "presetIndex",value = "预置点编号",paramType = "query",required = true,dataType = "int")
    })
    @RequestMapping(path = "/setPresetPoint",method = RequestMethod.POST)
    public ResultInfo setPresetPoint(String cameraIndexCode,String presetName,Integer presetIndex) {
        logger.info("预置点管理-设置预置点信息请求参数为：" + JSON.toJSONString(request.getParameterMap()));
        try {
            if (StrUtils.isNull(cameraIndexCode)) {
                return ResultInfo.renderError("监控点唯一标识不能为空");
            }
            if (StrUtils.isNull(presetName)) {
                return ResultInfo.renderError("预置点名称不能为空");
            }
            if (null == presetIndex) {
                return ResultInfo.renderError("预置点编号不能为空");
            }
            videoService.setPresetPoint(cameraIndexCode,presetName,presetIndex);
            return ResultInfo.renderSuccess("预置点管理-设置预置点信息成功");
        } catch (Exception e) {
            logger.error("预置点管理-设置预置点信息出现异常：" + e.getMessage(),e);
            return ResultInfo.renderError("预置点管理-设置预置点信息失败");
        }
    }

    @ApiOperation(value = "预置点管理-查询预置点信息",httpMethod = "POST",response = ResultInfo.class,notes = "预置点管理-查询预置点信息")
    @ApiImplicitParam(name = "cameraIndexCode",value = "监控点唯一编号",paramType = "query",required = true,dataType = "String")
    @RequestMapping(path = "/getPresetPoint",method = RequestMethod.POST)
    public ResultInfo getPresetPoint(String cameraIndexCode) {
        logger.info("预置点管理-查询预置点信息请求参数为：" + JSON.toJSONString(request.getParameterMap()));
        try {
            if (StrUtils.isNull(cameraIndexCode)) {
                return ResultInfo.renderError("监控点唯一标识不能为空");
            }
            ResponsePage resultPage = videoService.getPresetPoint(cameraIndexCode);
            return ResultInfo.renderSuccess(resultPage);
        } catch (Exception e) {
            logger.error("预置点管理-查询预置点信息出现异常：" + e.getMessage(),e);
            return ResultInfo.renderError("预置点管理-查询预置点信息失败");
        }
    }

    @ApiOperation(value = "预置点管理-删除预置点信息",httpMethod = "POST",response = ResultInfo.class,notes = "预置点管理-删除预置点信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cameraIndexCode",value = "监控点唯一编号",paramType = "query",required = true,dataType = "String"),
            @ApiImplicitParam(name = "presetIndex",value = "预置点编号",paramType = "query",required = true,dataType = "String")
    })
    @RequestMapping(path = "/deletePresetPoint",method = RequestMethod.POST)
    public ResultInfo deletePresetPoint(String cameraIndexCode,String presetIndex) {
        logger.info("预置点管理-删除预置点信息请求参数为：" + JSON.toJSONString(request.getParameterMap()));
        try {
            if (StrUtils.isNull(cameraIndexCode)) {
                return ResultInfo.renderError("监控点唯一标识不能为空");
            }
            if (StrUtils.isNull(presetIndex)) {
                return ResultInfo.renderError("预置点编号不能为空");
            }
            videoService.deletePresetPoint(cameraIndexCode,presetIndex);
            return ResultInfo.renderSuccess("预置点管理-删除预置点信息成功");
        } catch (Exception e) {
            logger.error("预置点管理-删除预置点信息出现异常：" + e.getMessage(),e);
            return ResultInfo.renderError("预置点管理-删除预置点信息失败");
        }
    }

    @ApiOperation(value = "预置点管理-批量获取监控点的预置点信息",httpMethod = "POST",response = ResultInfo.class,notes = "预置点管理-批量获取监控点的预置点信息")
    @ApiImplicitParam(name = "idList",value = "监控点唯一标识集和",paramType = "query",required = true,dataType = "String")
    @RequestMapping(path = "/batchQueryCameraIndexCodeInfo",method = RequestMethod.POST)
    public ResultInfo batchQueryCameraIndexCodeInfo(String idList) {
        logger.info("预置点管理-批量获取监控点的预置点信息请求参数为：" + JSON.toJSONString(request.getParameterMap()));
        try {
            if (StrUtils.isNull(idList)) {
                return ResultInfo.renderError("监控点唯一标识集和不能为空");
            }
            String[] cameraIndexCodes = idList.split(",");
            videoService.batchQueryCameraIndexCodeInfo(cameraIndexCodes);
            return ResultInfo.renderSuccess("预置点管理-批量获取监控点的预置点信息成功");
        } catch (Exception e) {
            logger.error("预置点管理-批量获取监控点的预置点信息出现异常：" + e.getMessage(),e);
            return ResultInfo.renderError("预置点管理-批量获取监控点的预置点信息失败");
        }
    }

    @ApiOperation(value = "图片获取-平台抓拍计划图片获取",httpMethod = "POST",response = ResultInfo.class,notes = "图片获取-平台抓拍计划图片获取")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "sTime",value = "开始时间",paramType = "query",required = true,dataType = "String"),
            @ApiImplicitParam(name = "eTime",value = "结束时间",paramType = "query",required = true,dataType = "String")
    })
    @RequestMapping(path = "/getPlatformSnapped",method = RequestMethod.POST)
    public ResultInfo getPlatformSnapped(String sTime,String eTime) {
        logger.info("图片获取-平台抓拍计划图片获取请求参数为：" + JSON.toJSONString(request.getParameterMap()));
        try {
            if (StrUtils.isNull(sTime)) {
                return ResultInfo.renderError("开始时间不能为空");
            }
            if (StrUtils.isNull(eTime)) {
                return ResultInfo.renderError("结束时间不能为空");
            }
            videoService.getPlatformSnapped(sTime,eTime);
            return ResultInfo.renderSuccess("图片获取-平台抓拍计划图片获取成功");
        } catch (Exception e) {
            logger.error("图片获取-平台抓拍计划图片获取出现异常：" + e.getMessage(),e);
            return ResultInfo.renderError("图片获取-平台抓拍计划图片获取失败");
        }
    }

    @ApiOperation(value = "图片获取-视频图片查询",httpMethod = "POST",response = ResultInfo.class,notes = "图片获取-视频图片查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "svrIndexCode",value = "图片存储服务器唯一标识",paramType = "query",required = true,dataType = "String"),
            @ApiImplicitParam(name = "picUri",value = "图片的相对地址",paramType = "query",required = true,dataType = "String")
    })
    @RequestMapping(path = "/getVideoImages",method = RequestMethod.POST)
    public ResultInfo getVideoImages(String svrIndexCode,String picUri) {
        logger.info("图片获取-视频图片查询请求参数为：" + JSON.toJSONString(request.getParameterMap()));
        try {
            if (StrUtils.isNull(svrIndexCode)) {
                return ResultInfo.renderError("图片存储服务器唯一标识不能为空");
            }
            if (StrUtils.isNull(picUri)) {
                return ResultInfo.renderError("图片的相对地址不能为空");
            }
            videoService.getVideoImages(svrIndexCode,picUri);
            return ResultInfo.renderSuccess("图片获取-视频图片查询成功");
        } catch (Exception e) {
            logger.error("图片获取-视频图片查询出现异常：" + e.getMessage(),e);
            return ResultInfo.renderError("图片获取-视频图片查询失败");
        }
    }

    @ApiOperation(value = "巡航路径-查询巡航路径",httpMethod = "GET",response = ResultInfo.class,notes = "巡航路径-查询巡航路径")
    @ApiImplicitParam(name = "cameraIndexCode",value = "监控点唯一编号",paramType = "query",required = true,dataType = "String")
    @RequestMapping(path = "/getCruisePath",method = RequestMethod.GET)
    public ResultInfo getCruisePath(String cameraIndexCode) {
        logger.info("巡航路径-查询巡航路径请求参数为：" + JSON.toJSONString(request.getParameterMap()));
        try {
            if (StrUtils.isNull(cameraIndexCode)) {
                return ResultInfo.renderError("监控点唯一编号不能为空");
            }
            videoService.getCruisePath(cameraIndexCode);
            return ResultInfo.renderSuccess("巡航路径-查询巡航路径成功");
        } catch (Exception e) {
            logger.error("巡航路径-查询巡航路径出现异常：" + e.getMessage(),e);
            return ResultInfo.renderError("巡航路径-查询巡航路径失败");
        }
    }

    @ApiOperation(value = "巡航路径-编辑巡航路径",httpMethod = "POST",response = ResultInfo.class,notes = "巡航路径-编辑巡航路径")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cameraIndexCode",value = "监控点唯一标识",paramType = "query",required = true,dataType = "String"),
            @ApiImplicitParam(name = "cruiseIndex",value = "巡航路径序号",paramType = "query",required = true,dataType = "int"),
            @ApiImplicitParam(name = "presetPointIndex",value = "预置点序号",paramType = "query",required = true,dataType = "int"),
            @ApiImplicitParam(name = "speed",value = "速度",paramType = "query",required = true,dataType = "int"),
            @ApiImplicitParam(name = "standingTime",value = "停留时间",paramType = "query",required = true,dataType = "int")
    })
    @RequestMapping(path = "/editorCruisePath",method = RequestMethod.POST)
    public ResultInfo editorCruisePath() {
        logger.info("巡航路径-编辑巡航路径请求参数为：" + JSON.toJSONString(request.getParameterMap()));
        try {
            String cameraIndexCode = StrUtils.isCheckNull(request.getParameter("cameraIndexCode"));
            String cruiseIndex = StrUtils.isCheckNull(request.getParameter("cruiseIndex"));
            String presetPointIndex = StrUtils.isCheckNull(request.getParameter("presetPointIndex"));
            String speed = StrUtils.isCheckNull(request.getParameter("speed"));
            String standingTime = StrUtils.isCheckNull(request.getParameter("standingTime"));
            if (StrUtils.isNull(cameraIndexCode)) {
                return ResultInfo.renderError("监控点唯一标识不能为空");
            }
            if (StrUtils.isNull(cruiseIndex)) {
                return ResultInfo.renderError("巡航路径序号不能为空");
            }
            if (StrUtils.isNull(presetPointIndex)) {
                return ResultInfo.renderError("预置点序号不能为空");
            }
            if (StrUtils.isNull(speed)) {
                return ResultInfo.renderError("速度不能为空");
            }
            if (StrUtils.isNull(standingTime)) {
                return ResultInfo.renderError("停留时间不能为空");
            }
            videoService.editorCruisePath(cameraIndexCode,Integer.valueOf(cruiseIndex),Integer.valueOf(presetPointIndex),Integer.valueOf(speed),Integer.valueOf(standingTime));
            return ResultInfo.renderSuccess("巡航路径-编辑巡航路径成功");
        } catch (Exception e) {
            logger.error("巡航路径-编辑巡航路径出现异常：" + e.getMessage(),e);
            return ResultInfo.renderError("巡航路径-编辑巡航路径失败");
        }
    }

    @ApiOperation(value = "巡航路径-删除巡航路径",httpMethod = "POST",response = ResultInfo.class,notes = "巡航路径-删除巡航路径")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cameraIndexCode",value = "监控点唯一编号",paramType = "query",required = true,dataType = "String"),
            @ApiImplicitParam(name = "cruiseIndex",value = "巡航路径序号",paramType = "query",required = true,dataType = "int")
    })
    @RequestMapping(path = "/deleteCruisePath",method = RequestMethod.POST)
    public ResultInfo deleteCruisePath() {
        logger.info("巡航路径-删除巡航路径请求参数为：" + JSON.toJSONString(request.getParameterMap()));
        try {
            String cameraIndexCode = StrUtils.isCheckNull(request.getParameter("cameraIndexCode"));
            String cruiseIndex = StrUtils.isCheckNull(request.getParameter("cruiseIndex"));
            if (StrUtils.isNull(cameraIndexCode)) {
                return ResultInfo.renderError("监控点唯一编号不能为空");
            }
            if (StrUtils.isNull(cruiseIndex)) {
                return ResultInfo.renderError("巡航路径序号不能为空");
            }
            videoService.deleteCruisePath(cameraIndexCode,Integer.valueOf(cruiseIndex));
            return ResultInfo.renderSuccess("巡航路径-删除巡航路径成功");
        } catch (Exception e) {
            logger.error("巡航路径-删除巡航路径出现异常：" + e.getMessage(),e);
            return ResultInfo.renderError("巡航路径-删除巡航路径失败");
        }
    }

    @ApiOperation(value = "巡航路径-巡航路径控制",httpMethod = "POST",response = ResultInfo.class,notes = "巡航路径-巡航路径控制")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cameraIndexCode",value = "监控点唯一编号",paramType = "query",required = true,dataType = "String"),
            @ApiImplicitParam(name = "command",value = "控制命令",paramType = "query",required = true,dataType = "String"),
            @ApiImplicitParam(name = "cruiseIndex",value = "巡航路径序号",paramType = "query",required = true,dataType = "int")
    })
    @RequestMapping(path = "/controlCruisePath",method = RequestMethod.POST)
    public ResultInfo controlCruisePath() {
        logger.info("巡航路径-巡航路径控制请求参数为：" + JSON.toJSONString(request.getParameterMap()));
        try {
            String cameraIndexCode = StrUtils.isCheckNull(request.getParameter("cameraIndexCode"));
            String command = StrUtils.isCheckNull(request.getParameter("command"));
            String cruiseIndex = StrUtils.isCheckNull(request.getParameter("cruiseIndex"));
            if (StrUtils.isNull(cameraIndexCode)) {
                return ResultInfo.renderError("监控点唯一编号不能为空");
            }
            if (StrUtils.isNull(command)) {
                return ResultInfo.renderError("控制命令不能为空");
            }
            if (StrUtils.isNull(cruiseIndex)) {
                return ResultInfo.renderError("巡航路径序号不能为空");
            }
            videoService.controlCruisePath(cameraIndexCode,command,cruiseIndex);
            return ResultInfo.renderSuccess("巡航路径-巡航路径控制成功");
        } catch (Exception e) {
            logger.error("巡航路径-巡航路径控制出现异常：" + e.getMessage(),e);
            return ResultInfo.renderError("巡航路径-巡航路径控制失败");
        }
    }

    @ApiOperation(value = "视频参数配置-获取视频OSD显示参数",httpMethod = "GET",response = ResultInfo.class,notes = "视频参数配置-获取视频OSD显示参数")
    @ApiImplicitParam(name = "cameraIndexCode",value = "监控点唯一编号",paramType = "query",required = true,dataType = "String")
    @RequestMapping(path = "/getVideoOSDDisplayParameters",method = RequestMethod.GET)
    public ResultInfo getVideoOSDDisplayParameters() {
        logger.info("视频参数配置-获取视频OSD显示参数请求参数为：" + JSON.toJSONString(request.getParameterMap()));
        try {
            String cameraIndexCode = StrUtils.isCheckNull(request.getParameter("cameraIndexCode"));
            if (StrUtils.isNull(cameraIndexCode)) {
                return ResultInfo.renderError("监控点唯一编号不能为空");
            }
            videoService.getVideoOSDDisplayParameters(cameraIndexCode);
            return ResultInfo.renderSuccess("视频参数配置-获取视频OSD显示参数成功");
        } catch (Exception e) {
            logger.error("视频参数配置-获取视频OSD显示参数出现异常：" + e.getMessage(),e);
            return ResultInfo.renderError("视频参数配置-获取视频OSD显示参数失败");
        }
    }

    @ApiOperation(value = "视频参数配置-获取视频叠加字符串参数",httpMethod = "GET",response = ResultInfo.class,notes = "视频参数配置-获取视频叠加字符串参数")
    @ApiImplicitParam(name = "cameraIndexCode",value = "监控点唯一编号",paramType = "query",required = true,dataType = "String")
    @RequestMapping(path = "/getVideoOverLayString",method = RequestMethod.GET)
    public ResultInfo getVideoOverLayString() {
        logger.info("视频参数配置-获取视频叠加字符串参数请求参数为：" + JSON.toJSONString(request.getParameterMap()));
        try {
            String cameraIndexCode = StrUtils.isCheckNull(request.getParameter("cameraIndexCode"));
            if (StrUtils.isNull(cameraIndexCode)) {
                return ResultInfo.renderError("监控点唯一编号不能为空");
            }
            videoService.getVideoOverLayString(cameraIndexCode);
            return ResultInfo.renderSuccess("视频参数配置-获取视频叠加字符串参数成功");
        } catch (Exception e) {
            logger.error("视频参数配置-获取视频叠加字符串参数出现异常：" + e.getMessage(),e);
            return ResultInfo.renderError("视频参数配置-获取视频叠加字符串参数失败");
        }
    }

    @ApiOperation(value = "视频参数配置-获取预览画面参数配置",httpMethod = "GET",response = ResultInfo.class,notes = "视频参数配置-获取预览画面参数配置")
    @ApiImplicitParam(name = "cameraIndexCode",value = "监控点唯一编号",paramType = "query",required = true,dataType = "String")
    @RequestMapping(path = "/getVideoParams",method = RequestMethod.GET)
    public ResultInfo getVideoParams() {
        logger.info("视频参数配置-获取预览画面参数配置请求参数为：" + JSON.toJSONString(request.getParameterMap()));
        try {
            String cameraIndexCode = StrUtils.isCheckNull(request.getParameter("cameraIndexCode"));
            if (StrUtils.isNull(cameraIndexCode)) {
                return ResultInfo.renderError("监控点唯一编号不能为空");
            }
            videoService.getVideoParams(cameraIndexCode);
            return ResultInfo.renderSuccess("视频参数配置-获取预览画面参数配置成功");
        } catch (Exception e) {
            logger.error("视频参数配置-获取预览画面参数配置出现异常：" + e.getMessage(),e);
            return ResultInfo.renderError("视频参数配置-获取预览画面参数配置失败");
        }
    }

    @ApiOperation(value = "视频参数配置-设置视频OSD显示参数",httpMethod = "POST",response = ResultInfo.class,notes = "视频参数配置-设置视频OSD显示参数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cameraIndexCode",value = "监控点唯一编号",paramType = "query",required = true,dataType = "String"),
            @ApiImplicitParam(name = "channelName",value = "通道名称",paramType = "query",required = true,dataType = "String"),
            @ApiImplicitParam(name = "isShowChanName",value = "是否显示通道名称，0-不显示；1-显示",paramType = "query",required = true,dataType = "int"),
            @ApiImplicitParam(name = "channelNameXPos",value = "通道名称显示X坐标",paramType = "query",required = true,dataType = "int"),
            @ApiImplicitParam(name = "channelNameYPos",value = "通道名称显示Y坐标",paramType = "query",required = true,dataType = "int"),
            @ApiImplicitParam(name = "hourOSDType",value = "小时制，0代表24小时制；1代表12小时制",paramType = "query",required = true,dataType = "int"),
            @ApiImplicitParam(name = "isShowOSD",value = "是否显示OSD，0-不显示；1-显示",paramType = "query",required = true,dataType = "int"),
            @ApiImplicitParam(name = "osdXPos",value = "OSD显示X坐标",paramType = "query",required = true,dataType = "int"),
            @ApiImplicitParam(name = "osdYPos",value = "OSD显示Y坐标",paramType = "query",required = true,dataType = "int"),
            @ApiImplicitParam(name = "osdType",value = "OSD显示类型值",paramType = "query",required = true,dataType = "int"),
            @ApiImplicitParam(name = "osdAttrib",value = "OSD属性，1-透明,闪烁；2-透明,不闪烁；3-闪烁,不透明；4-不透明,不闪烁",paramType = "query",required = true,dataType = "int"),
            @ApiImplicitParam(name = "isShowWeek",value = "是否显示星期，0-不显示；1-显示",paramType = "query",required = true,dataType = "int")
    })
    @RequestMapping(path = "/setOSDParams",method = RequestMethod.POST)
    public ResultInfo setOSDParams() {
        logger.info("视频参数配置-设置视频OSD显示参数请求参数为：" + JSON.toJSONString(request.getParameterMap()));
        try {
            String cameraIndexCode = StrUtils.isCheckNull(request.getParameter("cameraIndexCode"));
            String channelName = StrUtils.isCheckNull(request.getParameter("channelName"));
            String isShowChanName = StrUtils.isCheckNull(request.getParameter("isShowChanName"));
            String channelNameXPos = StrUtils.isCheckNull(request.getParameter("channelNameXPos"));
            String channelNameYPos = StrUtils.isCheckNull(request.getParameter("channelNameYPos"));
            String hourOSDType = StrUtils.isCheckNull(request.getParameter("hourOSDType"));
            String isShowOSD = StrUtils.isCheckNull(request.getParameter("isShowOSD"));
            String osdXPos = StrUtils.isCheckNull(request.getParameter("osdXPos"));
            String osdYPos = StrUtils.isCheckNull(request.getParameter("osdYPos"));
            String osdType = StrUtils.isCheckNull(request.getParameter("osdType"));
            String osdAttrib = StrUtils.isCheckNull(request.getParameter("osdAttrib"));
            String isShowWeek = StrUtils.isCheckNull(request.getParameter("isShowWeek"));
            if (StrUtils.isNull(cameraIndexCode)) {
                return ResultInfo.renderError("监控点唯一编号不能为空");
            }
            if (StrUtils.isNull(channelName)) {
                return ResultInfo.renderError("通道名称不能为空");
            }
            if (StrUtils.isNull(isShowChanName)) {
                return ResultInfo.renderError("是否显示通道名称不能为空");
            }
            if (StrUtils.isNull(channelNameXPos)) {
                return ResultInfo.renderError("通道名称显示X坐标不能为空");
            }
            if (StrUtils.isNull(channelNameYPos)) {
                return ResultInfo.renderError("通道名称显示Y坐标不能为空");
            }
            if (StrUtils.isNull(hourOSDType)) {
                return ResultInfo.renderError("小时制不能为空");
            }
            if (StrUtils.isNull(isShowOSD)) {
                return ResultInfo.renderError("是否显示OSD不能为空");
            }
            if (StrUtils.isNull(osdXPos)) {
                return ResultInfo.renderError("OSD显示X坐标不能为空");
            }
            if (StrUtils.isNull(osdYPos)) {
                return ResultInfo.renderError("OSD显示Y坐标不能为空");
            }
            if (StrUtils.isNull(osdType)) {
                return ResultInfo.renderError("OSD显示类型值不能为空");
            }
            if (StrUtils.isNull(osdAttrib)) {
                return ResultInfo.renderError("OSD属性不能为空");
            }
            if (StrUtils.isNull(isShowWeek)) {
                return ResultInfo.renderError("是否显示星期不能为空");
            }
            VideoOSDVo videoOSDVo = new VideoOSDVo();
            videoOSDVo.setCameraIndexCode(cameraIndexCode);
            videoOSDVo.setChannelName(channelName);
            videoOSDVo.setIsShowChanName(Integer.valueOf(isShowChanName));
            videoOSDVo.setChannelNameXPos(Integer.valueOf(channelNameXPos));
            videoOSDVo.setChannelNameYPos(Integer.valueOf(channelNameYPos));
            videoOSDVo.setHourOSDType(Integer.valueOf(hourOSDType));
            videoOSDVo.setIsShowOSD(Integer.valueOf(isShowOSD));
            videoOSDVo.setOsdXPos(Integer.valueOf(osdXPos));
            videoOSDVo.setOsdYPos(Integer.valueOf(osdYPos));
            videoOSDVo.setOsdType(Integer.valueOf(osdType));
            videoOSDVo.setOsdAttrib(Integer.valueOf(osdAttrib));
            videoOSDVo.setIsShowWeek(Integer.valueOf(isShowWeek));
            videoService.setOSDParams(videoOSDVo);
            return ResultInfo.renderSuccess("视频参数配置-设置视频OSD显示参数成功");
        } catch (Exception e) {
            logger.error("视频参数配置-设置视频OSD显示参数出现异常：" + e.getMessage(),e);
            return ResultInfo.renderError("视频参数配置-设置视频OSD显示参数失败");
        }
    }

    @ApiOperation(value = "视频参数配置-设置预览画面参数配置",httpMethod = "POST",response = ResultInfo.class,notes = "视频参数配置-设置预览画面参数配置")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cameraIndexCode",value = "监控点唯一编号",paramType = "query",required = true,dataType = "String"),
            @ApiImplicitParam(name = "brightness",value = "亮度，范围：[1,10]",paramType = "query",required = true,dataType = "int"),
            @ApiImplicitParam(name = "hue",value = "灰度，范围：[1,10]",paramType = "query",required = true,dataType = "int"),
            @ApiImplicitParam(name = "contrast",value = "对比度，范围：[1,10]",paramType = "query",required = true,dataType = "int"),
            @ApiImplicitParam(name = "saturation",value = "饱和度，范围：[1,10]",paramType = "query",required = true,dataType = "int"),
    })
    @RequestMapping(path = "/setPreViewPictureParams",method = RequestMethod.POST)
    public ResultInfo setPreViewPictureParams() {
        logger.info("视频参数配置-设置预览画面参数配置请求参数为：" + JSON.toJSONString(request.getParameterMap()));
        try {
            String cameraIndexCode = StrUtils.isCheckNull(request.getParameter("cameraIndexCode"));
            String brightness = StrUtils.isCheckNull(request.getParameter("brightness"));
            String hue = StrUtils.isCheckNull(request.getParameter("hue"));
            String contrast = StrUtils.isCheckNull(request.getParameter("contrast"));
            String saturation = StrUtils.isCheckNull(request.getParameter("saturation"));
            if (StrUtils.isNull(cameraIndexCode)) {
                return ResultInfo.renderError("监控点唯一编号不能为空");
            }
            if (StrUtils.isNull(brightness)) {
                return ResultInfo.renderError("亮度不能为空");
            }
            if (StrUtils.isNull(hue)) {
                return ResultInfo.renderError("灰度不能为空");
            }
            if (StrUtils.isNull(contrast)) {
                return ResultInfo.renderError("对比度不能为空");
            }
            if (StrUtils.isNull(saturation)) {
                return ResultInfo.renderError("饱和度不能为空");
            }
            videoService.setPreViewPictureParams(cameraIndexCode,Integer.valueOf(brightness),Integer.valueOf(hue),Integer.valueOf(contrast),Integer.valueOf(saturation));
            return ResultInfo.renderSuccess("视频参数配置-设置预览画面参数配置成功");
        } catch (Exception e) {
            logger.error("视频参数配置-设置预览画面参数配置出现异常：" + e.getMessage(),e);
            return ResultInfo.renderError("视频参数配置-设置预览画面参数配置失败");
        }
    }

    @ApiOperation(value = "视频参数配置-设置视频叠加字符串参数",httpMethod = "POST",response = ResultInfo.class,notes = "视频参数配置-设置视频叠加字符串参数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cameraIndexCode",value = "监控点唯一编号",paramType = "query",required = true,dataType = "String"),
            @ApiImplicitParam(name = "showString",value = "叠加字符串文本内容",paramType = "query",required = true,dataType = "String"),
            @ApiImplicitParam(name = "isShow",value = "是否显示叠加内容，0-不显示；1-显示",paramType = "query",required = true,dataType = "int"),
            @ApiImplicitParam(name = "xPos",value = "显示X坐标",paramType = "query",required = true,dataType = "int"),
            @ApiImplicitParam(name = "yPos",value = "显示Y坐标",paramType = "query",required = true,dataType = "int")
    })
    @RequestMapping(value = "/setVideoOverLayString",method = RequestMethod.POST)
    public ResultInfo setVideoOverLayString() {
        logger.info("视频参数配置-设置视频叠加字符串参数请求参数为：" + JSON.toJSONString(request.getParameterMap()));
        try {
            String cameraIndexCode = StrUtils.isCheckNull(request.getParameter("cameraIndexCode"));
            String showString = StrUtils.isCheckNull(request.getParameter("showString"));
            String isShow = StrUtils.isCheckNull(request.getParameter("isShow"));
            String xPos = StrUtils.isCheckNull(request.getParameter("xPos"));
            String yPos = StrUtils.isCheckNull(request.getParameter("yPos"));
            if (StrUtils.isNull(cameraIndexCode)) {
                return ResultInfo.renderError("监控点唯一编号不能为空");
            }
            if (StrUtils.isNull(showString)) {
                return ResultInfo.renderError("叠加字符串文本内容不能为空");
            }
            if (StrUtils.isNull(isShow)) {
                return ResultInfo.renderError("是否显示叠加内容不能为空");
            }
            if (StrUtils.isNull(xPos)) {
                return ResultInfo.renderError("显示X坐标不能为空");
            }
            if (StrUtils.isNull(yPos)) {
                return ResultInfo.renderError("显示Y坐标不能为空");
            }
            videoService.setVideoOverLayString(cameraIndexCode,showString,Integer.valueOf(isShow),Integer.valueOf(xPos),Integer.valueOf(yPos));
            return ResultInfo.renderSuccess("视频参数配置-设置视频叠加字符串参数成功");
        } catch (Exception e) {
            logger.error("视频参数配置-设置视频叠加字符串参数出现异常：" + e.getMessage(),e);
            return ResultInfo.renderError("视频参数配置-设置视频叠加字符串参数失败");
        }
    }
}
